package com.itheima.d4_create_thread;

/**
 * 目标：掌握线程的创建方式一:继承Thread类
 */
public class ThreadTest1 {
    // main方法是由一条默认的主线程负责执行。
    public static void main(String[] args) throws InterruptedException {
        //创建线程对象
//        MyThread mt1 = new MyThread();

        MyThread mt1 = new MyThread("小强");
        mt1.start();
        new MyThread("小美").start();
        new MyThread("小绿").start();
        //主线程中
        for (int i = 0; i < 10; i++) {
            System.out.println("老大"+i);
        }

    }
}
//写类继承thread
class MyThread extends Thread {
    private String name;

    public MyThread() {
    }

    public MyThread(String name) {
        this.name = name;
    }

    //重写run方法

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(name+i);
        }
    }
}
